//-------------------------------------------------------------------
//-------------------------------------------------------------------
#include "ioport.h"



//-------------------------------------------------------------------
void uart_send (unsigned int x )
{
//    while (( GET32(UART_USR) & 0x04) == 0) continue;
    while (( GET32(UART_LSR) & 0x40) == 0) continue;
    PUT32(UART_THR,x);
}
//-------------------------------------------------------------------
unsigned int uart_recv ( void )
{
    while (( GET32(UART_LSR) & 0x01) == 0) continue;
    return(GET32(UART_RBR));
}
//-------------------------------------------------------------------
void uart_init(void)
{
    // if(GET32(UART_IER) & 0xC0)
    //     PUT32(UART_THR, 'E');
    // else
    //     PUT32(UART_THR, 'D');
}
//-------------------------------------------------------------------
void uart_fifo_flush ( void )
{
    while (( GET32(UART_LSR) & 0x40) == 0) continue;
}
//-------------------------------------------------------------------------
void hexstrings (unsigned int d )
{
    unsigned int rb;
    volatile unsigned int rc;

    rb = 32;
    while(rb)
    {
        rb -= 4;
        rc = (d >> rb) & 0xF;
        if(rc > 9)
            rc += 0x37;
        else
            rc += 0x30;
        uart_send(rc);
    }
    uart_send(0x20);
}
//-------------------------------------------------------------------------
void hexstring ( unsigned int d )
{
    hexstrings(d);
    uart_send(0x0D);
    uart_send(0x0A);
}


//-------------------------------------------------------------------
//-------------------------------------------------------------------
